package com.admin.action.login_verify_action;

import com.admin.Action;
import com.admin.service.login_verify_service.LoginVerifyServiceImpl;
import com.pojo.AdminBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 验证管理员名和密码
 */
public class ValueDateAdminAction extends Action {
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out=response.getWriter();
        HttpSession session = request.getSession();
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }


        String username = request.getParameter("username");
        System.out.println(username);
        String phone = request.getParameter("phone");
        System.out.println(phone);
        AdminBean adminBean = new AdminBean();
        adminBean.setAdminName(username);
        adminBean.setAdminPhone(phone);
        System.out.println("————————————"+adminBean.getAdminName());
        LoginVerifyServiceImpl loginVerifyService = new LoginVerifyServiceImpl();
        boolean b=loginVerifyService.regAdminCheck(adminBean);
        System.out.println("9i9i9i9----"+b);
        if(b){ out.print(false);

        }else{
            out.print(true);
        }


    }
}
